package month5.day11;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Client {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        Socket s = new Socket("127.0.0.1", 18080);

        PrintStream ps = new PrintStream(s.getOutputStream(), true);
        while (true) {
            ps.println(in.nextLine());
            try {
                BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
                //按行接收信息
                String msg= br.readLine();
                if(msg.contains("exit"))
                    break;
                System.out.println(msg);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        }
    }
}
